package com.spr.utils;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileUtils {
  public static String readFileString(String fileName) throws IOException {
      BufferedReader reader = new BufferedReader(new FileReader(fileName));
      StringBuilder stringBuilder = new StringBuilder();
      String line = null;
      String ls = System.getProperty("line.separator");
      while ((line = reader.readLine()) != null) {
          stringBuilder.append(line);
          stringBuilder.append(ls);
      }
        // 删除最后一个新行分隔符
      stringBuilder.deleteCharAt(stringBuilder.length() - 1);
      reader.close();

      String content = stringBuilder.toString();

        return content;


  }

    public static void main(String[] args) {
        String s = null;
        try {
            s = readFileString("D:\\gitee\\demo\\springboot系列\\Spring Boot (0) 初始demo\\src\\main\\java\\com\\hyzhang\\utils\\133.json");
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("s = " + s);

    }

}
